﻿namespace System.IO
{
    /// <summary>
    /// BinaryReader扩展类
    /// </summary>
    public static class BinaryReaderEx
    {
        /// <summary>
        /// 读取数据
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="buffer"></param>
        public static void Read(this BinaryReader reader, Span<byte> buffer)
        {
            for (int i = 0; i < buffer.Length; i++)
            {
                buffer[i] = reader.ReadByte();
            }
        }

        /// <summary>
        /// 读取数据
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="buffer"></param>
        public static void Read(this BinaryReader reader, Span<char> buffer)
        {
            for (int i = 0; i < buffer.Length; i++)
            {
                buffer[i] = reader.ReadChar();
            }
        }
    }
}
